﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BPM.Common;

namespace BPM.Entity
{
	public abstract class BaseEntity
	{
		public int Id { get; set; }

		/// <summary>
		/// EF会主动来读取外键。需要一个变量来进行区分。
		/// </summary>
		public bool EnableLazyLoading;

		/// <summary>
		/// 创建一个使用延迟加载的外键的引用
		/// </summary>
		/// <typeparam name="TRefEntity"></typeparam>
		/// <param name="staticLoader"></param>
		/// <returns></returns>
		protected ILazyEntityRef<TRefEntity> CreateReference<TRefEntity>()
			where TRefEntity : BaseEntity
		{
			return new LazyEntityRef<TRefEntity>(this);
		}

		public virtual Result Validate()
		{
			return true;
		}
	}
}